package org.hackday.evetteam;


import android.app.Activity;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Button;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;

import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.Button;

import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.Resources;

public class PeopleActivity extends Activity implements OnClickListener, OnItemClickListener {

	private Button buttonView;
	private Button buttonCreate;
	private Button buttonFeeds;
	private TextView text;
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.people);
        
        buttonView = (Button) findViewById(R.id.view);
        this.buttonView.setOnClickListener(this);
        
        buttonCreate = (Button) findViewById(R.id.create);
        this.buttonCreate.setOnClickListener(this);
        
        buttonFeeds = (Button) findViewById(R.id.feeds);
        this.buttonFeeds.setOnClickListener(this);
        
        showMap();
        
    }
    
    
    private void showMap()
	{
		WebView webview = (WebView) findViewById(R.id.map);
		webview.setWebViewClient(new WebViewClient());
		webview.getSettings().setJavaScriptEnabled(true);
		webview.setVerticalScrollBarEnabled(false);
		
		String url ="http://172.16.6.92:8080/EventsServer/people.html";
				
				//"http://maps.google.com/maps/api/staticmap?center="+ stop_lon+","+ stop_lat + "&zoom=15&size=440x80&maptype=roadmap&markers=color:red%7Ccolor:red%7Clabel:C%7C"+ stop_lon +"," +stop_lat + "&sensor=true";
		System.out.println(url);
		webview.loadUrl(url);
		

	}
    
    
    public void onClick(View v) {

		
				String text = "Whoa! You haven't selected your current stop. Please pick one from the list!";
				
				int duration = Toast.LENGTH_SHORT;
			 Context context; 
				context = getApplicationContext();
				Toast toast = Toast.makeText(context, text, duration);
				//toast.setGravity(Gravity.CENTER, 0, 0);
				//toast.show();
			
			//startActivity(i1);
				
				switch (v.getId()) {
				case R.id.create:
				
				Intent i = new Intent(this, AsyncHttp.class);
				//i.putExtra(BusAdapter.STOP_ID, stopId);
				startActivity(i);
                break;
                
                
				case R.id.feeds:
					
					Intent i1 = new Intent(this, ContactSelector.class);
					//i.putExtra(BusAdapter.STOP_ID, stopId);
					startActivity(i1);
	                break;
	                
				case R.id.view:
					
					Intent i2 = new Intent(this, AsyncHttp.class);
					//i.putExtra(BusAdapter.STOP_ID, stopId);
					startActivity(i2);
	                break;
				}
		


	}

	public void onItemClick(AdapterView<?> arg0, View arg1, int listIndex,
			long arg3) {
		
	}

	

	
	
}